package com.hue.concurrent.day01;

import java.util.concurrent.locks.LockSupport;

/*
    打断park线程
 */
public class Demo12 {
    public static void main(String[] args) {
        Thread t1 = new Thread(() -> {
            System.out.println("park");
            //park只有在打断标记为false时才会生效
            LockSupport.park();
            System.out.println("unpark1");
            System.out.println("打断标记:" + Thread.currentThread().isInterrupted());
            //清除打断标记
            Thread.interrupted();
            LockSupport.park();
            System.out.println("unpark2");
        }, "t1");
        t1.start();

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        t1.interrupt();
    }
}
